import java.io.*;
import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {

    }
    public static void main3(String[] args) {

        try (InputStream inputStream = new FileInputStream("d:/test.txt")) {
            // 此时 scanner 就是从文件读取了!!
            Scanner scanner = new Scanner(inputStream);
            // 就可以使用 scanner 读取后续的数据.
            String s = scanner.next();
            System.out.println(s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main4(String[] args) {
        try (OutputStream outputStream = new FileOutputStream("d:/test.txt",true)) {
        PrintWriter e=new PrintWriter(outputStream);

         e.println("hello");
         e.flush();
        }catch (IOException e){
            throw new RuntimeException();
        };

    }
    public static void main1(String[] args) {
       try(Writer writer=new FileWriter("d:/test.txt") ){
           writer.write("wwwww");
        }catch (IOException e){
           throw  new RuntimeException();
       }
    }
}
